<extend name="Public/base"/>

<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu"/>
</block>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title cf">
        <h2>
            编辑{$data.model_id|get_document_model='title'} [
            <volist name="rightNav" id="nav">
                <a href="{:U('article/index','cate_id='.$nav['id'])}">{$nav.title}</a>
                <if condition="count($rightNav) gt $i"><i class="ca"></i></if>
            </volist>
            <present name="article">：<a
                    href="{:U('article/index','cate_id='.$data['category_id'].'&pid='.$article['id'])}">{$article.title}</a>
            </present>
            ]
        </h2>
    </div>
    <!-- 标签页导航 -->
    <div class="tab-wrap">
        <ul class="tab-nav nav">
            <volist name=":parse_config_attr($model['field_group'])" id="group">
                <li data-tab="tab{$key}"
                <eq name="key" value="1">class="current"</eq>
                ><a href="javascript:void(0);">{$group}</a></li>
            </volist>
        </ul>
        <div class="tab-content">
            <!-- 表单 -->
            <form id="form" action="{:U('personal_edit')}" method="post" class="form-horizontal">
                <!-- 基础文档模型 -->
                <input type="hidden" name="id" value="{$data['id']}">
                <div class="form-item cf">
                    <label class="item-label">name</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="name" value="{$data['name']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">gender</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="gender" value="{$data['gender']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">jobinten</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="jobinten" value="{$data['jobinten']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">mobile</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="mobile" value="{$data['mobile']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">email</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="email" value="{$data['email']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">education</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="education" value="{$data['education']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">region</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="region" value="{$data['region']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">pay</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="pay" value="{$data['pay']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">worktime</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="worktime" value="{$data['worktime']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">position</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="position" value="{$data['position']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">company</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="company" value="{$data['company']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">studytime</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="studytime" value="{$data['studytime']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">major</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="major" value="{$data['major']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">school</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="school" value="{$data['school']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">self</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="self" value="{$data['self']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">picture</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="picture" value="{$data['picture']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">age</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="age" value="{$data['age']}"></div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">year</label>
                    <div class="controls">
                        <input type="text" class="text input-large" name="year" value="{$data['year']}"></div>
                </div>
                <div class="form-item cf">
                    <button class="btn submit-btn   hidden"  type="submit"
                            >确 定
                    </button>
                    <a class="btn btn-return" href="{$Think.cookie.__forward__}">返 回</a>
                    <if condition="C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)">
                        <button class="btn save-btn" url="{:U('article/autoSave')}" target-form="form-horizontal"
                                id="autoSave">
                            存草稿
                        </button>
                    </if>
                    <input type="hidden" name="id" value="{$data.id|default=''}"/>
                    <input type="hidden" name="pid" value="{$data.pid|default=''}"/>
                    <input type="hidden" name="model_id" value="{$data.model_id|default=''}"/>
                    <input type="hidden" name="group_id" value="{$data.group_id|default=''}"/>
                    <input type="hidden" name="category_id" value="{$data.category_id|default=''}">
                </div>
            </form>
        </div>
    </div>
</block>

<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '
        <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">
        ';
    </php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
            charset="UTF-8"></script>
    <script type="text/javascript">

        Think.setValue("type", {$data.type |
        default
        = '""'
        })
        ;
        Think.setValue("display", {$data.display |
        default
        = 0
        })
        ;

        $('#submit').click(function () {
            $('#form').submit();
        });

        $(function () {
            $('.date').datetimepicker({
                format: 'yyyy-mm-dd',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });
            $('.time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });
            showTab();

        <
            if condition = "C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)" >
            //保存草稿
                var interval;
            $('#autoSave').click(function () {
                var target_form = $(this).attr('target-form');
                var target = $(this).attr('url')
                var form = $('.' + target_form);
                var query = form.serialize();
                var that = this;

                $(that).addClass('disabled').attr('autocomplete', 'off').prop('disabled', true);
                $.post(target, query).success(function (data) {
                    if (data.status == 1) {
                        updateAlert(data.info, 'alert-success');
                        $('input[name=id]').val(data.data.id);
                    } else {
                        updateAlert(data.info);
                    }
                    setTimeout(function () {
                        $('#top-alert').find('button').click();
                        $(that).removeClass('disabled').prop('disabled', false);
                    }, 1500);
                })

                //重新开始定时器
                clearInterval(interval);
                autoSaveDraft();
                return false;
            });

            //Ctrl+S保存草稿
            $('body').keydown(function (e) {
                if (e.ctrlKey && e.which == 83) {
                    $('#autoSave').click();
                    return false;
                }
            });

            //每隔一段时间保存草稿
            function autoSaveDraft() {
                interval = setInterval(function () {
                    //只有基础信息填写了，才会触发
                    var title = $('input[name=title]').val();
                    var name = $('input[name=name]').val();
                    var des = $('textarea[name=description]').val();
                    if (title != '' || name != '' || des != '') {
                        $('#autoSave').click();
                    }
                }, 1000 * parseInt({
            :
                C('DRAFT_AOTOSAVE_INTERVAL')
            }))
                ;
            }

            autoSaveDraft();

        <
            /if>

        });
    </script>
</block>
